<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

	<f:metadata>
		<f:event type="preRenderView" listener="#{userBean.navigateToMainIfNotSystemAdminOrModerator}" />
	</f:metadata>

	<ui:composition template="generalTemplate.xhtml">
		<ui:define name="title">
		    Makaleler · Yönetim
		</ui:define>
		<ui:define name="content">
		
			<!-- Page Header -->
			<header class="jumbotron subhead">
	    		<h1>Makaleler</h1>
	    		<p class="lead">
	    			Buradan onay bekleyen makaleleri yayına alabilir veya reddedebilir, 
	    			yayındaki makaleleri yayından kaldırabilir, ve dilerseniz makaleleri silebilirsiniz.
	    		</p>
	  		</header>
	  		<!-- /Page Header -->
			
			<div class="row">
				<div class="span2">
						<ul class="nav nav-list" style="padding: 0px;">
							<li>
								<h3 style="line-height: 36px; font-size: 19.5px; font-weight: normal;">
									Menü
								</h3>
							</li>
							<li>								
								<h:link outcome="moderateArticles">
									<i class="icon-ok-circle"></i> Yayındakiler
									<f:param name="confirmationStatus" value="CONFIRMED" />
								</h:link>
							</li>
							<li>
								<h:link outcome="moderateArticles">
									<i class="icon-question-sign"></i> Onay Bekleyenler
									<f:param name="confirmationStatus" value="PENDING" />
								</h:link>
							</li>
							<li>
								
								<h:link outcome="moderateArticles">
									<i class="icon-ban-circle"></i> Reddedilmişler
									<f:param name="confirmationStatus" value="NOT_CONFIRMED" />
								</h:link>
							</li>
							<li>
								<h:link outcome="moderateArticles">
									<i class="icon-trash"></i> Silinmişler
									<f:param name="confirmationStatus" value="DELETED" />
								</h:link>
							</li>
						</ul>
				</div><!-- end of span2 -->
				
				<div class="span10">
					<c:if test="#{moderateArticlesBackingBean.confirmationStatus == 'CONFIRMED'}">
						<legend>Yayınlanmakta Olan Makaleler</legend>	
					</c:if>
					<c:if test="#{moderateArticlesBackingBean.confirmationStatus == 'PENDING'}">
						<legend>Onay Bekleyen Makaleler</legend>	
					</c:if>
					<c:if test="#{moderateArticlesBackingBean.confirmationStatus == 'NOT_CONFIRMED'}">
						<legend>Reddedilmiş Makaleler</legend>	
					</c:if>
					<c:if test="#{moderateArticlesBackingBean.confirmationStatus == 'DELETED'}">
						<legend>Silinmiş Makaleler</legend>	
					</c:if>
					
					<c:if test="#{empty moderateArticlesBackingBean.articleList}">
						Yok ki...
					</c:if>		
					<h:dataTable styleClass="table"
								value="#{moderateArticlesBackingBean.articleList}"
								var="article"
								rendered="#{! empty moderateArticlesBackingBean.articleList}">
						<h:column>
							<f:facet name="header">Makale</f:facet>
							<div class="submitDiv">
								<h:link value="#{article.title}"
										outcome="articleDetail">
									<f:param name="articleId" value="#{article.id}" />
								</h:link>
							</div>
						</h:column>
						<h:column>
						<f:facet name="header">Yazar</f:facet>
							<div class="submitDiv">
								<h:link value="#{article.author.fullName}"
										outcome="profile"
										rel="tooltip"
										data-toggle="tooltip"
										title="Profiline git">
									<f:param name="userId" value="#{article.author.id}" />
								</h:link>
							</div>
						</h:column>
						<h:column rendered="#{moderateArticlesBackingBean.confirmationStatus ne 'DELETED'}">
							<h:form style="padding: 0px; margin: 0px;">
								<div class="submitDiv">
									<h:commandLink rendered="#{moderateArticlesBackingBean.confirmationStatus eq 'CONFIRMED'}"
												value="Yayından Kaldır"
												action="#{moderateArticlesBackingBean.cancelArticleConfirmationAction(article)}">
										<f:param name="confirmationStatus"
												value="#{moderateArticlesBackingBean.confirmationStatus}" />
										<f:ajax execute="@form" render="@all" />
									</h:commandLink>
									<h:commandLink rendered="#{moderateArticlesBackingBean.confirmationStatus ne 'CONFIRMED'}"
												value="Yayınla"
												action="#{moderateArticlesBackingBean.confirmArticleAction(article)}">
										<f:param name="confirmationStatus"
												value="#{moderateArticlesBackingBean.confirmationStatus}" />
										<f:ajax execute="@form" render="@all" />
									</h:commandLink>
								</div>
							</h:form>
						</h:column>
						<h:column rendered="#{moderateArticlesBackingBean.confirmationStatus eq 'PENDING'}">
							<h:form style="padding: 0px; margin: 0px;">
								<div class="submitDiv">
									<h:commandLink value="Reddet"
												action="#{moderateArticlesBackingBean.rejectArticleAction(article)}">
										<f:param name="confirmationStatus"
												value="#{moderateArticlesBackingBean.confirmationStatus}" />
										<f:ajax execute="@form" render="@all" />
									</h:commandLink>
								</div>
							</h:form>
						</h:column>
						<h:column rendered="#{moderateArticlesBackingBean.confirmationStatus eq 'DELETED'}">
							<h:form style="padding: 0px; margin: 0px;">
								<div class="submitDiv">
									<h:commandLink value="Yayınla"
												action="#{moderateArticlesBackingBean.confirmArticleAction(article)}">
										<f:param name="confirmationStatus"
												value="#{moderateArticlesBackingBean.confirmationStatus}" />
										<f:ajax execute="@form" render="@all" />
									</h:commandLink>
								</div>
							</h:form>
						</h:column>
						<h:column>
							<h:form style="padding: 0px; margin: 0px;">
								<div class="submitDiv">
									<h:commandLink rendered="#{moderateArticlesBackingBean.confirmationStatus ne 'DELETED'}"
												value="Sil"
												action="#{moderateArticlesBackingBean.deleteArticleAction(article)}">
										<f:param name="confirmationStatus"
												value="#{moderateArticlesBackingBean.confirmationStatus}" />
										<f:ajax execute="@form" render="@all" />
									</h:commandLink>
									<h:commandLink rendered="#{moderateArticlesBackingBean.confirmationStatus eq 'DELETED'}"
												value="Sil (Kalıcı Olarak)"
												action="#{moderateArticlesBackingBean.deleteArticlePermanentlyAction(article)}">
										<f:param name="confirmationStatus"
												value="#{moderateArticlesBackingBean.confirmationStatus}" />
										<f:ajax execute="@form" render="@all" />
									</h:commandLink>
								</div>
							</h:form>
						</h:column>
					</h:dataTable>
				</div><!-- end of span10 -->
			</div><!-- end of row -->
		</ui:define>
	</ui:composition>
</html>